<template>
  <Teleport to="#app" v-if="visible">
    <div class="modal">
      <div class="modal_main">
        <div class="modal__content">
          {{ content }}
        </div>
        <div>

          <el-button
              size="large"
              type="primary"

              @click.native.prevent="submitForm"
          >
            确定
          </el-button>
          <el-button size="large"
                     type="primary" @click="cancel">取 消
          </el-button>
        </div>
      </div>

    </div>
  </Teleport>
</template>

<script>
import {ref, reactive} from "vue";
import {ElButton} from 'element-plus'

export default {
  name: "modal",
  components: {ElButton},
  props: {
    content: {
      type: String,
      default: ""
    }
  },
  setup() {
    let visible = ref(false);
    const submitForm = () => {
      visible.value = false
    }
    const cancel = () => {
      visible.value = false
    }
    const open = (content) => {
      visible.value = true
    }

    return {
      visible,
      submitForm,
      cancel,
      open,
    }
  },
  data() {
    return {}
  },
  created() {
  },
  mounted() {
  },

  methods: {},
  computed: {},
  watch: {},
  beforeDestroy() {
  },
  destroyed() {
  }
}
</script>

<style scoped lang="scss">
.modal {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 199;
  background: rgba(0, 0, 0, 0.5);

  &_main {
    position: relative;
    width: 350px;
    height: 200px;
    margin-top: 80px;
    margin-left: auto;
    margin-right: auto;
    background: #fff;
    border-radius: 5px;
  }
}

</style>